package pages;

import finds.Finder;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import java.util.List;

/**
 * Created by 13714526025 on 2018/9/20.
 * 手动添加页面控件封装
 */
public class HandAddPage {
    private AndroidDriver<WebElement> driver;
    private Finder finder;

    public HandAddPage(Finder finder) {
        this.finder = finder;
    }

    //根据索引选择品类
    public void selectForIndexClick(int index) {
        finder.findElementsById("com.oppo.ohome:id/ll_item", index).click();
    }

    //根据索引选择WLAN
    public void selectWLANForIndex(int index) {
        finder.findElementsById("com.oppo.ohome:id/tv_wlan_title", index).click();
    }

    //选择xiyouji002的WLAN
    public void xiyouji002Wlan() {
        //得到所有的WLAN列表
        List<WebElement> wlanList = driver.findElements(By.id("com.oppo.ohome:id/tv_wlan_title"));
        //遍历得到每一个wifi
        for (int x = 0; x < wlanList.size(); x++) {
            String wifiName = wlanList.get(x).getText();//得到每一个wifi,将wifi名转换成字符串

            if (wifiName.equals("xiyouji002")) {//判断是否出现xiyouji002的wifi，如果存在，就点击进入下一步
                finder.findElementByText("xiyouji002").click();

            }

        }

    }
    //返回
    public void goBack(){
        finder.findElementById("com.oppo.ohome:id/support_up").click();
    }
    //下一步按钮
    public void nextBtnClick(){
        finder.findElementById("com.oppo.ohome:id/btn_next").click();
    }


}
